﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;

//using Microsoft.VisualStudio.TestTools.UnitTesting;

//using invrt;
//using Pibby.Core.IO;
//using Pibby.Core.Playlist;
//using Pibby.Core.IntegrationTests.Stubs;

//namespace Pibby.Core.Tests
//{
//    [TestClass]
//    public class M3uPlaylistTests : IntegrationBaseTestFixture
//    {
//        [TestMethod]
//        public void LoadFrom_EmptyList_ReturnsNoContent()
//        {
//            M3uPlaylistGenerator generator = new M3uPlaylistGenerator();
//            generator.HowManyItems = 0;

//            MediaPlaylist playlist = M3uPlaylistReader.LoadFrom(generator.ContentStream);

//            //Assert.IsEmpty(playlist.Items);
//        }

//        [TestMethod]
//        public void LoadFrom_PopulatedPlaylist_ReadsContent()
//        {
//            M3uPlaylistGenerator generator = new M3uPlaylistGenerator();
//            generator.HowManyItems = 10;

//            MediaPlaylist playlist = M3uPlaylistReader.LoadFrom(generator.ContentStream);

//            Assert.AreEqual(10, playlist.Items.Count);
//        }

//        [TestMethod]
//        [ExpectedException (typeof(FileNotFoundException))]
//        public void LoadFrom_MissingFile_ThrowsException()
//        {
//            MediaPlaylist playlist = M3uPlaylistReader.LoadFrom("This_File_Does_Not_Exist.txt");
//        }

//        [TestMethod]
//        [ExpectedException(typeof(ArgumentNullException))]
//        public void LoadFrom_NullTextReader_ThrowsException()
//        {
//            TextReader reader = null;

//            MediaPlaylist playlist = M3uPlaylistReader.LoadFrom(reader);
//        }

//        //[TestMethod]
//        //public void LoadFrom_File_ReadsItemsCorrectly()
//        //{
//        //    Stubs.Folder folder = new Stubs.Folder ("G:\\", 1);
//        //    folder.FileExtension = "m3u";

//        //    MediaPlaylist playlist = M3uPlaylistReader.LoadFrom(folder.PathToFile ("File1.m3u"));


//        //}

//        [TestMethod]
//        public void CanWriteAndWritePlaylist()
//        {
//            M3uPlaylistGenerator generator = new M3uPlaylistGenerator();
//            generator.HowManyItems = 10;

//            MediaPlaylist playlist = M3uPlaylistReader.LoadFrom(generator.ContentStream);

//            StringBuilder builder = new StringBuilder();

//            string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
//            IFolder folder = new Folder(folderPath, 25, 0);

//            using (TextWriter writer = new StringWriter(builder))
//            {
//                M3uPlaylistWriter.SaveTo(writer, playlist, folder);
//            }

//            using (TextReader reader = new StringReader(builder.ToString()))
//            {
//                MediaPlaylist readPlaylist = M3uPlaylistReader.LoadFrom(reader);

//                Assert.AreEqual(playlist.Items.Count, readPlaylist.Items.Count);
//            }

//        }

//        [TestMethod]
//        public void LoadFrom_Folder_CreatesOneEntryPerFile()
//        {
//            Stubs.Folder folder = new Stubs.Folder("G:\\", 10);

//            MakePlaylist(folder);
//        }

//        private void MakePlaylist(IFolder folder)
//        {
//            string folderPath = folder.Path;
//            string [] parts = folderPath.Split ('\\');

//            string playlist = parts[parts.Length - 1];

//            if (string.IsNullOrEmpty(playlist))
//                playlist = "Playlist";

//            string playlistName = playlist + ".m3u";
			
//            MediaPlaylist folderListing = Playlist.MediaPlaylist.LoadFrom(folder);

//            Assert.AreEqual(folder.GetFiles().Count, folderListing.Items.Count);

//            if (folderListing.Items.Count > 0)
//                M3uPlaylistWriter.SaveTo(folder, playlistName, folderListing);

//            foreach (IFolder subFolder in folder.GetSubfolders())
//            {
//                MakePlaylist(subFolder);
//            }
//        }

//    }
//}
